import axios from "axios";
import { v4 as uuidv4 } from "uuid";

export const getOpenImAdminByToken = function () {
    const data = {
        "secret": "openIM123",
        "userID": "imAdmin"
    };
    return new Promise((resolve, reject) => {
        axios.post("https://imweb.uat.hd.astraia.cn/api/auth/get_admin_token", data, {
            headers: {
                operationID: uuidv4(),
            }})
            .then(res => {
                resolve(res.data);
            })
            .catch(err => reject(err))
    });

};


export const getOpenImSelfByToken = function (token, uid, platformID) {
    console.log('tokentokentoken', token);
    const data = {
        "platformID": platformID,
        "userID": uid
    };
    return new Promise((resolve, reject) => {
        axios.post("https://imweb.uat.hd.astraia.cn/api/auth/get_user_token", data, {
            headers: {
                operationID: uuidv4(),
                token,
            }})
            .then(res => {
                console.log('resres', res.data);
                resolve(res.data);
            })
            .catch(err => reject(err))
    });

};
